﻿

CREATE proc [Projects].[GetBusinessCases]
@ProjectID	int
as
begin
	set nocount on

	select	p.ProjectID, 
			p.Intern, 
			p.ShortName, 
			p.PurchaserID, 
			p.InvoiceToID,
			p.FirstContactDate, 
			p.FirstContactUserID, 
			p.[Address], 
			p.EPLZ, 
			p.ImplementationDate, 
			p.CustomerSource, 
			p.CustomerGroup, 
			p.CalculationUserID, 
			p.SalesUserID, 
			p.FileUserID, 
			p.CreateOn, 
			p.CreateBy, 
			p.LastChangedOn, 
			p.LastChangedBy, 
			p.ProjectStatus,
			p.OrderDate,
			p.FinishDate,
			p.FilePath,
			p.Saved,
			p.Distance,
			pa.GaToHm, 
			pa.GaToAl,
			pa.GaToDi, 
			pa.EiToSi, 
			pa.EiToFl, 
			pa.AnToSeRo, 
			pa.AnToSi, 
			pa.AnToFl, 
			pa.AnToSr, 
			pa.SbGa, 
			pa.SbGh, 
			pa.SbHs, 
			pa.AaEi, 
			pa.AaZa, 
			pa.AaGe, 
			pa.AaEf, 
			pa.Carport, 
			pa.LeDe, 
			pa.LeMo, 
			pa.LeUk, 
			pa.LeBr, 
			pa.LeBrAverage, 
			pa.LeRe, 
			pa.LeReAverage, 
			pa.LeBl, 
			pa.LeBlAverage,
			pv.ErloesSuHw,
			pv.ErloesSuPr,
			pv.ErloesSuMo,
			pv.ErloesSuGesamt,
			pv.ErloesRaPr,
			pv.ErloesRaLe,
			pv.ErloesRaPro,
			pv.ErloesSf,
			pv.ErloesEm,
			pv.ErloesFa,
			pv.ErloesSummary,
			pv.ErloesSuEsPercent,
			pv.ErloesSumNetto,
			pv.CostHandelsware,
			pv.CostProduktion,
			pv.CostMontage,
			pv.CostAdministration,
			pv.CostSummary,
			pv.CostSummaryPercent,
			pv.ExtraCostBIPercent,
			pv.ExtraCostBIFix,
			pv.ExtraCostPrEPercent,
			pv.ExtraCostPrEFix,
			pv.ExtraCostErfGar,
			pv.ExtraCostHaftRuecklage,
			pv.ExtraCostSkonto,
			pv.ExtraCostProvisionDB,
			pv.ExtraCostSummary,
			pv.ExtraCostSummaryPercent,
			pv.ResultDB,
			pv.ResultDBPercent,
			pv.TimeProduktion,
			pv.TimeMontage,
			pv.TimeAdministration,
			pv.TimeSummary
			
	from	Projects.datProjects p
			inner join Projects.datProjectsAttributes pa on
				pa.ProjectID = p.ProjectID
			inner join Projects.datProjectsValues pv on
				pv.ProjectID = p.ProjectID
	where	p.ProjectID = @ProjectID
	order by p.ShortName
end
GO


